import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;


public class testCentralServer 
{
	public static void main(String[] args)
	{
	    System.out.println("RMIServer started");
		if (System.getSecurityManager() == null) 
        {
            System.setSecurityManager(new RMISecurityManager());
            System.out.println("Security manager installed.");
        }
        else
            System.out.println("Security manager already exists.");

		try 
		{
			System.out.println("A");
			CentralServer xCentralServer = new CentralServer();
			//CentralServerInterface xCentralServer = new CentralServer();
			//CentralServerInterface xStub = (CentralServerInterface) UnicastRemoteObject.exportObject(xCentralServer, 0);

			System.out.println("B");
			//LocateRegistry.createRegistry(3000);
			//Registry xRegistry = LocateRegistry.getRegistry();
			System.out.println("C");
			//xRegistry.rebind("CentralServer", xStub);
			Naming.rebind ("//lin116-08/CentralServer",xCentralServer); 
			System.out.println ("Central Server is ready.");
		} 
		catch (Exception e) 
		{
			e.printStackTrace();
			System.out.println ("Central Server failed: " + e);
		}

	}

}
